package cn.edu.hunan.pm.controller;
import cn.edu.hunan.pm.Entity.PatentTransaction;
import cn.edu.hunan.pm.service.PatentTransactionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/transactions")
public class PatentTransactionController {
    @Autowired
    private PatentTransactionService patentTransactionService;

    @CrossOrigin
    @PostMapping
    public void addPatentTransaction(@RequestBody PatentTransaction patentTransaction) {
         patentTransactionService.addPatentTransaction(patentTransaction);
    }

    @CrossOrigin
    @DeleteMapping("/{transactionId}")
    public void deletePatentTransactionById(@PathVariable Integer transactionId) {
         patentTransactionService.deletePatentTransactionById(transactionId);
    }
    @CrossOrigin
    @PutMapping
    public void updatePatentTransaction(@RequestBody PatentTransaction patentTransaction) {
         patentTransactionService.updatePatentTransaction(patentTransaction);
    }
    @CrossOrigin
    @GetMapping("/{transactionId}")
    public PatentTransaction findPatentTransactionById(@PathVariable Integer transactionId) {
        return patentTransactionService.findPatentTransactionById(transactionId);
    }
    @CrossOrigin
    @GetMapping
    public List<PatentTransaction> findAllPatentTransactions() {
        return patentTransactionService.findAllPatentTransactions();
    }
}

